/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

//网点公众号管理
import { Request, Response } from 'express';
import { ResponseItem, responseSuccess } from './utils';
import type { Kbdby } from '@/pages/NetworkWx/index.d';
import Mock from 'mockjs';

export default {
  'POST /shopOpen/ajax': (req: Request, res: Response, u: string) => {
    let { action } = req.body;
    let data: any = [];
    const authOfficialAccountsList: Kbdby[] = Mock.mock({
      'list|10': [
        {
          'id|+1': 1,
          platform: 'wx_mini_134',
          platform_type: 'weixin',
          nick_name: '快宝云打印',
          'gh_id|1-10000000': 10000000,
          user_info: {
            name: '张三',
            phone: '13783636924',
          },
          is_franchisee: '1',
          franchisee_info: '荣昌快宝加盟商 13783636923',
          auth_time: Mock.Random.datetime('yyyy-MM-dd A HH:mm:ss'),
          auth_cancel_time: Mock.Random.datetime('yyyy-MM-dd A HH:mm:ss'),
          'is_close|0-1': 1,
          app_name: 'wx_mini_134',
        },
      ],
    });
    const authOfficialAccountsGet: Kbdby[] = Mock.mock({
      id: '8',
      app_id: 'wxb09d66967aa2c2d3',
      auth_app_id: 'wx62e2a1bdf62fa71e',
      auth_time: '2019-01-21 16:02:10',
      auth_code:
        'queryauthcode@@@ii0xacpp88jgh900TTPlYFtz5qV5Q96DVJGFrdeudgZ8s3QL3_SUzBGB0NFdHJ_6_VKp_GGVQtDi0XlqO_cz',
      auth_code_expire: '2019-01-21 17:02:10',
      pre_auth_code:
        'preauthcode@@@Yut3hyLZZeIlileAYfUK7Z9oePBi6MwNCXBOTa4mNMbGOuPs3GbOWgVrXiQtZBaG',
      is_auth: '1',
      auth_cancel_time: '',
      platform: 'wt_weixin_8',
      platform_type: 'weixin',
      nick_name: '嘚叻',
      create_time: '2019-01-21 16:02:11',
      update_time: '2019-01-21 16:02:11',
      is_close: '0',
      user_info: '',
      is_franchisee: '2',
      franchisee_info: '',
      gh_id: 'gh_7589daed6255',
    });
    const authInfo: Kbdby[] = Mock.mock({
      'id|+1': 1,
      'cloud_print|1-5': 5,
      'default_agent_guid|1-10000000': 10000000,
      'default_dak_id|1-1000000000': 1000000000,
      'default_courier_id|1-1000000000': 1000000000,
      welcome: '欢迎你',
      'dak_id|1-1000000000': 1000000000,
      tbk_title: '测试标题',
      tbk_url: 'https://',
      tbk_content: '23aaaaa',
      coupon: 1233,
      merchant_entry: '222',
      local_mall: '222',
      urgent_delivery: '222',
    });

    const addManager = Mock.mock({
      list: {
        content: 'http://weixin.qq.com/q/02ackocltJeDi1NqK4hx1q',
        sceneId: 390784601,
        url:
          'https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=gQFO7zwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyYWNrb2NsdEplRGkxTnFLNGh4MXEAAgQ6EsRhAwQgHAAA',
      },
    });

    const getManagerList = Mock.mock({
      'list|3': [
        {
          create_time: '2018-08-09 10:29:36',
          'id|1-1000': 1000,
          is_delete: '0',
          is_root: '0',
          iu_id: '2044981',
          nickname: '王现勇',
          open_platform: 'wt_mini_55',
          platform: 'weixin_shop_36',
          platform_type: 'weixin_mini',
          u_note: '王现勇',
          uid: 'o3S2n0oO7X1mNv2AE1XdChUQQBwQ',
          update_time: '2021-05-18 11:23:59',
        },
      ],
    });

    const wtMenuLink = Mock.mock({
      list:
        'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx72cd5847f07541f4&redirect_uri=2&scope=snsapi_base&response_type=code&state=wt_weixin_36&component_appid=wxb09d66967aa2c2d3#wechat_redirect',
    });

    if (action == 'authOfficialAccountsList') {
      data = authOfficialAccountsList;
    } else if (action == 'authOfficialAccountsGet') {
      data = authOfficialAccountsGet;
    } else if (action == 'authInfo') {
      data = authInfo;
    } else if (action == 'addManager') {
      data = addManager;
    } else if (action == 'getManagerList') {
      data = getManagerList;
    } else if (action == 'wtMenuLink') {
      data = wtMenuLink;
    }
    const result: ResponseItem = {
      code: 0,
      msg: '成功',
      data: data,
    };
    return res.json(result);
  },
  'POST /PushRemark/updateRemark': (req: Request, res: Response, u: string) =>
    responseSuccess(req, res),
};
